function  [j_max_mf_value,j_max_mf_index]  = exh_apeo_gpu_fft (n,min_peak,x_all_matrix,y_all_matrix)
    X_FFTs = fft_01(x_all_matrix);
    Y_FFTs = fft_01(y_all_matrix);

    y_len = size(y_all_matrix, 1);
    j_max_mf_index = zeros(y_len,1);
    j_max_mf_value = zeros(y_len,1);

    parfor j = 1: y_len        % 直接进行相关性计算，避免多次调用自定义函数
            

         [j_max_mf_value(j,1),j_max_mf_index(j,1) ]= compute_max_mfs_limit (n,Y_FFTs(j, :), ...
            X_FFTs,x_all_matrix,y_all_matrix(j,:),min_peak);
    
    end
end
function [ mfs_value , mfs_index] = compute_max_mfs_limit (n,Y_FFTs_j, X_FFTs,x_all_matrix,y_seq,min_peak)
    R=zeros(size(X_FFTs,1),2*n-1);
    peaks=zeros(size(X_FFTs,1),1);
    isls=zeros(size(X_FFTs,1),1);
    mfs=zeros(size(X_FFTs,1),1);
    correlation_results = zeros(size(X_FFTs,1),2*n-1);
    i = find(abs(n-2*sum(xor(y_seq , x_all_matrix),2)) > min_peak); %主峰的绝对值要大于
    
    R(i,:) = real(Y_FFTs_j .* conj(X_FFTs(i,:)));  % 计算相关性
    correlation_results(i,:) =  real(round(ifft(R(i,:), [], 2)));% 计算逆 FFT

    peaks(i) = correlation_results(i,1);
    isls(i) = sum(correlation_results(i,2:n).^2,2) ;
    mfs(i) = (peaks(i).^2)./isls(i)/2;

    [ mfs_value , mfs_index] = max(mfs);
end
function  x_fft = fft_01(array_01)
% 计算 x 和 y 的 FFT 相关性
x_seq = ones(size(array_01,1),size(array_01,2));
x_seq(array_01 == 0) = -1 ; % 将 0 转换为 -1
x_fft = fft(x_seq, size(x_seq,2)*2-1,2);  % 对 x 进行 FFT

end
